<script type="text/javascript" src="<?= base_url() ?>js/comment.js"></script>
<?php foreach($image_crud->css_files as $file): ?>
      <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($image_crud->js_files as $file): ?>
      <script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<div class="page-header">
    <h2><b>Hỏi đáp</b></h2>
</div>
<h3>
    <strong><em>Nội dung câu hỏi</em></strong>
</h3>
<div class="panel panel-info"  style="padding-top: 2px; padding-bottom: 2px;">
    <div class="row clearfix" style="padding-left: 7%;  padding-right: 4%;">
        <h3><strong><?= $question['tieude']; ?></strong></h3>
    </div>
    <div class="row">
        <div class="col-md-1"></div>
        <div class="col-md-6">Môn Học: <strong style="color: red;"><?= $monhoc; ?></strong></div>
        <div class="col-md-5">Được gửi bởi: <b><?= $username; ?></b></div>  
    </div>
    <div class="row text text-justify"  style="padding-left: 7%; padding-right: 4%;">
        <p>
            <small>
                <?php echo $question['noidung']; ?>
            </small>
        </p>
    </div>
    <div class="row text text-justify"  style="padding-left: 7%; padding-right: 4%;">
	<?php echo $image_crud->output; ?>
    </div>
</div>
<h3>
    <strong><em>Trả lời</em></strong>
</h3>
<div>
    <input type="hidden"  value="<?= base_url(); ?>" id='baseurl' />
    <div class="panel panel-info" style="padding: 10px;">
        <?php
        $sess = $this->session->userdata('logged_in');
        if ($sess['sign_in'] == TRUE) {
            $attr = array('class' => 'submitComment');
            echo form_open('hoidap/hoidap/add_comment', $attr);
            ?>
            <!-- Content 'comment_noidung' -->
            <textarea 
                style="background-color: #EEF9D9"
                class="form-control" rows="3" id="comment_noidung" name="comment_noidung" 
                placeholder="Trả lời tại đây ..."></textarea>
            <br>
            <p id="attention" class="text-danger" style="font-size:15px; display: none">Nội dung trả lời không được để trống.</p>
            <!-- Content 'hoidap_id' -->
            <input type="hidden" name="hoidap_id" value="<?= $question['id']; ?>">
            <div class="text-right">
                <button type="submit" class="btn btn-primary">Bình luận</button>
            </div>
            <?php echo form_close();?>
        <?php } else {
            /* $btnLogin = array(
              'class' => 'btn btn-primary',
              'name' => 'submit',
              'value' => 'Đăng nhập',
              ); */?>
            <div class="text-center">Đăng nhập để được tham gia bình luận.<br>
             <!-- form_open('thanhvien/thanhvien/login') .
              form_submit($btnLogin) .
              form_close() . '</div>'; */-->
          <?php echo form_open('thanhvien/thanhvien/plogin');?>
             <button type="submit" name="submit" class="btn btn-primary" value="2">Đăng Nhập</button>
          <?php echo form_close();?>
            </div>
        <?php } ?>
    </div>
    <div class="panel panel-info" style="padding: 2px;">
        <div id="insertBeforeMe"></div>
        <?php
        if (!empty($comment)) {
            foreach ($comment as $row):
                ?>
                <div class="panel panel-default" style="padding: 5px; margin: 1px;">
                    <div class="panel-body" style="padding-top: 0px; padding-bottom: 0px; margin: 2px;">
                        <div class="col-lg-1" style="padding-left: 0px;">
                            <img src="<?php echo base_url(); ?>/image/hoidap_detail/user<?= rand(1, 3)?>.png" height="40" width="40">
                        </div>
                        <div class="col-lg-11">
                            <strong><?= $row['username']; ?></strong><br>
                            <?= $row['noidung'] . '.'; ?>
                        </div>
                    </div>
                </div>
                <?php
            endforeach;
        } else {
            echo '<div class="text-center"><em>Hãy tham gia trả lời nhé.</em></div>';
        }
        ?>
    </div>
</div>